// 将字符串转换为node格式 用富文本rich-text展示
export function strToNode(keyWordArr = [], keyWordValue) {
    const keyWordNodes = []
    keyWordArr.forEach(item => {
        const nodes = []
        const isInclude = item.toUpperCase().startsWith(keyWordValue.toUpperCase())
        if (isInclude) {
            const str1 = item.slice(0, keyWordValue.length)
            const str2 = item.slice(keyWordValue.length)
            const node1 = {
                name: 'span',
                attrs: {
                    style: 'color:#25ce8a;'
                },
                children: [{
                    type: 'text',
                    text: str1
                }]
            }
            nodes.push(node1)
            const node2 = {
                name: 'span',
                attrs: {
                    style: 'color:black;'
                },
                children: [{
                    type: 'text',
                    text: str2
                }]
            }
            nodes.push(node2)

        } else {
            const node1 = {
                name: 'span',
                attrs: {
                    style: 'color:black;'
                },
                children: [{
                    type: 'text',
                    text: item
                }]
            }
            nodes.push(node1)
        }
        keyWordNodes.push(nodes)
    });
    return keyWordNodes
}
